<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2016/9/22
 * Time: 15:59
 */


$var_na2222me = 0;
function get_variable_name(&$var, $scope = NULL) {
    if (NULL == $scope) {
        $scope = $GLOBALS;
    }

    $tmp = $var;
    $var = "tmp_exists_" . mt_rand();
    $name = array_search($var, $scope, TRUE);
    $var = $tmp;
    return $name;
}
function vname(&$var, $scope=false, $prefix='unique', $suffix='value')
{
    if($scope) $vals = $scope;
    else $vals = $GLOBALS;
    $old = $var;
    $var = $new = $prefix.rand().$suffix;
    $vname = FALSE;
    foreach($vals as $key => $val) {
        if($val === $new) $vname = $key;
    }
    $var = $old;
    return $vname;
}

function test($abc){
    vname($abc);
}
//echo vname($var_na2222me);
//echo vname($gsdgsdgsdgsg);
